:: generate_proto.bat
@echo off

set curPath=%~dp0
set rootPath=%curPath%..\
set srcPath=%rootPath%src\
set protoPath=%rootPath%proto\

:: delete old go protoFile
if exist %srcPath%proto (
    del /S /Q %srcPath%proto
)

:: generate go source code
:: base
call:generateCode base\change_reason.proto
call:generateCode base\error_code.proto
call:generateCode base\logout_reason.proto
call:generateCode base\server.proto

:: server
call:generateCode server\center\message.proto
call:generateCode server\game\message.proto
call:generateCode server\gate\message.proto
call:generateCode server\login\message.proto

:: client
call:generateCode asset\message.proto
call:generateCode example\message.proto
call:generateCode item\message.proto
call:generateCode mail\message.proto
call:generateCode money\message.proto
call:generateCode player\message.proto


goto:eof

::--------------------------------------------------------
::-- Function section starts below here
::--------------------------------------------------------
:generateCode
setLocal

set protoFile=%protoPath%%~1
set outPath=%srcPath%
:: set outPath=%srcPath%%outPath%\

if not exist %outPath% (
    mkdir %outPath%
)

echo generate %protoFile%
protoc --proto_path %rootPath% --go_out=%outPath% %protoFile%

endLocal
goto:eof
